package com.version1.diabeco.ui.medicacion;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.SpinnerAdapter;
import android.widget.TextView;

import com.version1.diabeco.R;
import com.version1.diabeco.model.ajustes.medicamento.Medicamento;

public class MedicamentoSpinnerAdapter extends ArrayAdapter<Medicamento> implements SpinnerAdapter {
	
	public MedicamentoSpinnerAdapter(Context context, List<Medicamento> list) {
		super(context, android.R.layout.simple_spinner_dropdown_item, list);
	}

	public View getView(int position, View convertView, ViewGroup parent) {

		View spinView;
		if (convertView == null) {
			LayoutInflater vi = (LayoutInflater) this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			spinView = vi.inflate(R.layout.spinner_medicamento, null);
		} else {
			spinView = convertView;
		}

		TextView descripcion = (TextView) spinView.findViewById(R.id.descripcion);
		descripcion.setText(this.getItem(position).getDescripcion());

		return spinView;
		
	}
}